<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <!--{include file='comm/header.tpl'}-->
    <title>生产查询</title>
    <!--{include file='comm/comm_cal.tpl'}-->
    <!--{include file='comm/lodop.tpl'}-->
</head>
<body>
<!--{include file='comm/naviBanner.tpl'}-->

<div class="container">

    <!--{include file='comm/menu.tpl'}-->
    <div class="comm_crub">
        <span class="now_crub">生产查询</span>
    </div>

    <div class="comm_content">

            <div class="search-box">
                <div style="position:relative">
                    <form method="post" class="form-inline" onsubmit="return false;" id="search_form">
                        <table>
                            <tbody>
                            <tr>
                                <td height="27px">
                                    <span>配送日期：<input type="text" class="form-control input-sm" style="width:110px" value="<!--{$currentDate|default:''}-->" name="send_date" id="send_date"></span>
                                    <span>
                                        配送开始时间：
                                        <select name="send_start_time" id="send_start_time" class="form-control input-sm" style="width:80px;">
                                            <option value="">请选择</option>
                                            <script>
                                                for(var i=0;i < 24;i++){
                                                    if(i <10 ){
                                                        document.write('<option value="0'+ i +':00">' + "0"+i +':00 </option>');
                                                        document.write('<option value="0'+ i +':30">' + "0"+i +':30 </option>');
                                                    }else{
                                                        document.write('<option value="'+ i +':00">'  + i +':00 </option>');
                                                        document.write('<option value="'+ i +':30">'  + i +':30 </option>');
                                                    }
                                                }
                                            </script>

                                        </select>
                                    </span>

                                    <span>
                                        配送结束时间：
                                        <select name="send_end_time" id="send_end_time" class="form-control input-sm" style="width:80px;">
                                            <option value="">请选择</option>
                                            <script>
                                                for(var i=0;i < 24;i++){
                                                    if(i <10 ){
                                                        document.write('<option value="0'+ i +':00">' + "0"+i +':00 </option>');
                                                        document.write('<option value="0'+ i +':30">' + "0"+i +':30 </option>');
                                                    }else{
                                                        document.write('<option value="'+ i +':00">'  + i +':00 </option>');
                                                        document.write('<option value="'+ i +':30">'  + i +':30 </option>');
                                                    }
                                                }
                                            </script>
                                        </select>
                                    </span>

                                    <span>
                                       配送城市：<select id="cityID" name="cityID" class="form-control input-sm" style="width:100px;">
                                            <option value="" selected="">请选择</option>

                                        　　<!--{foreach from=$city item=res}-->
                                        　　 <option  value="<!--{$res['id']}-->"><!--{$res['name']}--></option>
                                        　　<!--{/foreach}-->

                                        </select>
                                    </span>

                                    <span>
                                        配送站：
                                        <select name="distribution_id" id="distribution_id" class="form-control input-sm" style="width:110px;">
                                            <option value="">请选择</option>
                                        </select>
                                    </span>

                                    <span>
                                        订单类型：
                                        <select name="billType" id="billType" class="form-control input-sm" style="width:100px;">

                                            <option value="">全部</option>
                                            <option value="1">正常订单</option>
                                            <option value="2">试吃订单</option>
                                            <option value="3">大客户订单</option>
                                            <option value="4">赠送订单</option>
                                            <option value="5">赔偿订单</option>
                                            <option value="6">内部订单</option>
                                        </select>
                                    </span>

                                    <span>订单号：<input type="text" class="form-control input-sm" style="width:110px" value="" name="bill_no" id="bill_no"></span>
                                    <span>SKU/品名：<input type="text" class="form-control input-sm" style="width:110px" value="" name="sku" id="sku"></span>

                                    <span>
                                        是否切分：
                                        <select name="segmentation" id="segmentation" class="form-control input-sm" style="width:100px;">

                                            <option value="">全部</option>
                                            <option value="1">是</option>
                                            <option value="0">否</option>

                                        </select>
                                    </span>

                                    <span>
                                        含生日牌：
                                        <select name="birthday_card" id="birthday_card" class="form-control input-sm" style="width:100px;">

                                            <option value="">全部</option>
                                            <option value="1">是</option>
                                            <option value="0">否</option>

                                        </select>
                                    </span>

                                    <span>
                                        是否打印：
                                        <select name="print_num" id="print_num" class="form-control input-sm" style="width:100px;">

                                            <option value="">全部</option>
                                            <option value="1">是</option>
                                            <option value="0">否</option>

                                        </select>
                                    </span>

                                    <span><input type="button" onclick="productSearch.search();" class="btn btn-primary" value="查询"></span>
                                    <span><input type="button" onclick="productSearch.reSet();" class="btn btn-warning" value="重置"></span>

                                    <span><input  value="打印"  onclick="productSearch.print();" class="btn btn-default" type="button"></span>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </form>
                </div>
            </div>

            <table id="flex" style="display:none;"></table>

        </div>

</div>
<script type="text/javascript">
    $('#send_date').datetimepicker();

    $("#flex").flexigrid({
        url:"/invokingAjax-backend/production/productionSearch.ajax?operFlg=1",
        dataType: "json",
        colModel : [
            {display: "序号",width : 60,align:"center"},
            {display: "城市", width : 90,align:"left"},
            {display: "订单标示", width : 80,align:"left"},
            {display: "订单类型", width : 90,align:"left"},
            {display: "配送日期", width : 90,align:"center"},
            {display: "配送开始时间", width : 90,align:"center"},
            {display: "配送结束时间", width : 90,align:"center"},
            {display: "下单时间", width : 140,align:"center"},
            {display: "打印次数", width : 70,align:"center"},
            {display: "订单号", width : 140,align:"center"},
            {display: "配送站", width : 120,align:"left"},
            {display: "商品编号", width : 180,align:"left"},
            {display: "商品名称", width : 280,align:"left"},
            {display: "规格", width : 240,align:"left"},
            {display: "商品数量", width : 60,align:"left"},
            {display: "餐具数量", width : 60,align:"left"},
            {display: "生日牌", width : 180,align:"left"},
            {display: "切分", width : 60,align:"left"},
            {display: "生产要求", width : 200,align:"left"}
        ],
        buttons : [
            {name: "全选", bclass: "checkAll", onpress : "E.checkAllList"},
            {separator: true},
            {name: "取消全选", bclass: "cancelCheckAll", onpress : "E.cancelCheckAllList"}
        ],
        sortname: "send_date",
        sortorder: "desc",
        usepager: true,
        rp: 50,
        useRp: true,
        showTableToggleBtn: true,
        onSubmit: function() {
            var dt = $('#search_form').serializeArray();
            $("#flex").flexOptions({params: dt});
            return true;
        }
    });

    var productSearch= {

        //头部 按条件查询
        search: function() {
            var dt = $('#search_form').serializeArray();
            $("#flex").flexOptions({params: dt}).flexReload();
        },

        //重置
        reSet:function(){
            $("#send_date").val('<!--{$currentDate}-->');
            $("#send_start_time").val('');
            $("#send_end_time").val('');
            $("#cityID").val('');
            $("#distribution_id").val('');
            var html ='<option value="">请选择</option>';
            $("#distribution_id").html(html);
            $("#billType").val('');
            $("#bill_no").val('');
            $("#sku").val('');
            $("#segmentation").val('');
            $("#birthday_card").val('');
            $("#print_num").val('');
            productSearch.load();
        },

        //刷新页面
        load: function() {
            $("#flex").flexReload();
        },

        //导出数据
        exportTable: function () {

            E.confirm('您确认导出数据吗？','productSearch.export_todo');

        },

        //执行导出数据
        export_todo: function () {

            var searchForm = document.getElementById('search_form');

            searchForm.action = '/quanliadmin/app/production/productionSearch.pscript?operFlg=2'//导出数据

            searchForm.submit();

        },

        //打印
        print:function( scan_id ){

            var send_date = $('#send_date').val();
            var deliver_cityid = $('#deliver_cityid').val();

            jquery_ajax(2,{send_date:send_date,deliver_cityid:deliver_cityid},productSearch.printBack);

        },

        //打印回调函数
        printBack:function( obj ){

            if( obj.code != 200 ){
                E.alert( obj.message );
            }else{
                var scan_id = LODOP.outPrint( obj.data );
            }

        }


    };


    function jquery_ajax(flg,data,func){
        $.ajax({
            type: "post",
            url: "/invokingAjax-backend/production/productionSearch.ajax?operFlg="+flg,
            dataType: "json",
            data: data,
            success: function( result_obj ) {
                func(result_obj);
            },
            error : function(msg){
                E.alert('网络不给力，请重新尝试...',1);
            }
        });
    };

    $("#cityID").change(function(){ //城市=>配送站二级下拉菜单
        var value = $(this).val();
        if(value == false){
            html ='<option value="">请选择</option>';
            $("#distribution_id").html(html);
            return;
        }
        $.ajax({
            type:"post",
            url:"/invokingAjax-backend/production/productionSearch.ajax?operFlg=3",
            dataType:"json",
            data:"cityID="+value,
            success:function(res){
                if( res.code == 200 ){
                    var html;
                    for(var i=0;i<res.data.length;i++){
                        var data = res['data'][i];
                        html +="<option value="+data.id+">"+data.name+"</option>";
                    };
                    $("#distribution_id").html(html);
                }
            }
        });
    });
</script>

</body>
</html>